package com.hyopt.common.utils;

import cn.hutool.core.lang.Singleton;

import java.util.UUID;

/**
 * @author liubin
 * @date 2020/1/10 14:15
 */
public final class UUIDUtils {

  private volatile static UUIDUtils instance = new UUIDUtils();

  private UUIDUtils(){}

  public static UUIDUtils getSingleton() {
    if (instance == null) {
      synchronized (Singleton.class) {
        if (instance == null) {
          instance = new UUIDUtils();
        }
      }
    }
    return instance;
  }

  public static String getUUID(){
    return UUID.randomUUID().toString().replace("-","");
  }


  public static Integer getUUIDInOrderId(){
    Integer orderId=UUID.randomUUID().toString().hashCode();
    orderId = orderId < 0 ? -orderId : orderId;
    //String.hashCode() 值会为空
    return orderId;
  }

}
